% 原始数据（价格区间）
price_range = {
    '2.50-4.00', '6.50-8.50', '7.50-9.00', '6.00-8.00', '6.00-7.50', ...
    '3.00-4.00', '2.50-3.50', '6.00-7.50', '5.50-6.50', '6.50-8.50', ...
    '30.00-50.00', '1.00-2.00', '2.50-4.00', '5.00-6.00', '3.00-4.00', ...
    '2.50-4.00', '6.50-8.50', '7.50-9.00', '6.00-8.00', '6.00-7.50', ...
    '3.00-4.00', '2.50-3.50', '6.00-7.50', '5.50-6.50', '6.50-8.50', ...
    '30.00-50.00', '1.00-2.00', '2.50-4.00', '5.00-6.00', '3.00-4.00', ...
    '2.50-4.00', '6.50-8.50', '7.50-9.00', '6.00-8.00', '6.00-7.50', ...
    '3.00-4.00', '2.50-3.50', '6.00-7.50', '5.50-6.50', '6.50-8.50', ...
    '30.00-50.00', '1.00-2.00', '2.50-4.00', '5.00-6.00', '3.00-4.00', ...
    '6.00-8.00', '7.00-9.00', '5.50-8.00', '5.00-8.00', '3.00-4.50', ...
    '5.00-7.50', '5.00-6.00', '4.80-6.70', '4.00-6.50', '5.00-6.00', ...
    '5.50-7.50', '4.00-6.00', '5.00-6.50', '6.00-8.00', '4.50-6.00', ...
    '6.00-8.50', '3.00-6.00', '4.00-5.00', '3.20-4.80', '7.00-9.00', ...
    '5.50-8.00', '5.00-8.00', '3.00-4.50', '5.00-7.50', '5.00-6.00', ...
    '4.80-6.70', '4.00-6.50', '5.00-6.00', '5.50-7.50', '4.00-6.00', ...
    '5.00-6.50', '6.00-8.00', '4.50-6.00', '6.00-8.50', '3.00-6.00', ...
    '4.00-5.00', '3.20-4.80', '2.00-3.00', '2.00-3.00', '2.50-4.00', ...
    '50.00-65.00', '18.00-20.00', '14.00-18.00', '80.00-120.00', ...
    '8.40-10.80', '6.60-9.60', '6.00-9.60', '3.60-5.40', '6.00-9.00', ...
    '6.00-7.20', '5.80-8.00', '5.80-7.80', '6.00-7.20', '6.60-9.00', ...
    '4.80-7.20', '6.00-7.80', '7.20-9.60', '5.40-7.20', '7.20-10.20', ...
    '3.60-7.20', '4.80-6.00', '3.80-5.80'
};

% 初始化两个数组来存储最小和最大值%t1
price_min = zeros(length(price_range), 1);
price_max = zeros(length(price_range), 1);
price_median = zeros(length(price_range), 1);  % 存储中位数

% 处理区间数据
for i = 1:length(price_range)
    % 分割字符串，提取区间的最小和最大值
    range = strsplit(price_range{i}, '-');
    price_min(i) = str2double(range{1});
    price_max(i) = str2double(range{2});
    
    % 计算区间的中位数
    price_median(i) = (price_min(i) + price_max(i)) / 2;
end

% 绘制原始数据区间（最小值和最大值）
figure;
hold on;
bar(price_min, 'FaceColor', [0.2, 0.6, 0.5]);%t1
bar(price_max, 'FaceColor', [0.5, 0.2, 0.8]);
title('原始销售单价区间');
xlabel('作物编号');
ylabel('销售单价 (元/斤)');
legend({'最低单价', '最高单价'});
hold off;

% 绘制处理后的中位数数据
figure;
bar(price_median);
title('销售单价的中位数');
xlabel('作物编号');
ylabel('销售单价中位数 (元/斤)');

% 绘制原始数据区间（最小值和最大值），更新颜色
figure;
hold on;
bar(price_min, 'FaceColor', [0.1, 0.7, 0.1]); % 将最低单价设置为绿色%t1
bar(price_max, 'FaceColor', [0.6, 0.6, 0.6]); % 将最高单价设置为灰色
title('原始销售单价区间');
xlabel('作物编号');
ylabel('销售单价 (元/斤)');
legend({'最低单价', '最高单价'});
hold off;

